package com.file;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicLong;

public class TestWrite {
	

	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws Exception {
		final AtomicLong number = new AtomicLong();
		new Thread(new Runnable() {
			@Override
			public void run() {
				while(true){
					File dir = new File("d:/home/admin/t.log");
					FileWriter fos;
					try {
						fos = new FileWriter(dir, false);
						fos.write("111111111111111");
						fos.close();
						number.incrementAndGet();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}

			}
		}).start();
		
    	Timer timer = new Timer();
    	timer.scheduleAtFixedRate(new TimerTask(){
			@Override
			public void run() {
				System.out.println(number.getAndSet(0));
			}

    	}, 0, 1*1000);
		

	}
	

}
